package test01;

import java.util.Random;

class Rgb extends Thread {
    private String color;
    private Random random = new Random();

    public Rgb(String color) {
        this.color = color;
    }

    @Override
    public void run() {
        while (true) {
            int value = random.nextInt(256); // 生成 0-255 之间的随机数
            System.out.println(color + ": " + value);
            try {
                Thread.sleep(1000); // 每秒输出一次
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}